using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_admin_EditArchives : System.Web.UI.UserControl
{
    public void Refresh()
    {
        gridArchive.DataSource = DAL.Archives.All();
        gridArchive.DataBind();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Refresh();
        }
    }

    protected void SaveArchive(object sender, CommandEventArgs e)
    {
        long id;
        if (Int64.TryParse(e.CommandArgument.ToString(), out id))
        {
            TextBox txtArchive = (TextBox)((Control)sender).FindControl("txtArchive");
            if (txtArchive != null)
            {
                DAL.Archive myArchive = DAL.Archives.Item(id);
                if (myArchive != null)
                {
                    myArchive.Title = txtArchive.Text;
                    DAL.Archives.Save(myArchive);
                }
            }
        }
    }
}
